//
//  KStoreRequest.m
//  Peanut
//
//  Created by Jim huang on 2018/4/11.
//  Copyright © 2018年 Jim_Peanut. All rights reserved.
//

#import "KStoreRequest.h"
#import "KStoreAPI.h"

@implementation KStoreRequest



/**
 商品列表
 
 @param name 名称 商品名字
 @param order 排序 1=升序，2=降序
 @param orderType 排序  1=综合，2=价格，3=销量
 @param page 当前页
 @param subCateId 分类id
 @param type     产品类型  1=花生宝商城，2=花宝商城，3=乐享商城
 */
-(instancetype)initStoreListWithName:(NSString *)name order:(NSString *)order orderType:(NSString *)orderType page:(NSString *)page subCateId:(NSString *)subCateId type:(NSString *)type{
    
    
    if (self = [super initGETWithRequestUrl:KStoreListURL]) {

        [self.paramsDic setValue:name forKey:@"name"];
        [self.paramsDic setValue:order forKey:@"order"];
        [self.paramsDic setValue:orderType forKey:@"orderType"];
        [self.paramsDic setValue:page forKey:@"page"];
        [self.paramsDic setValue:@"10" forKey:@"pageSize"];
        [self.paramsDic setValue:subCateId forKey:@"cateId"];
        [self.paramsDic setValue:type forKey:@"type"];

    }
    return self;
}


/**
 获取商城轮播图
 */
-(instancetype)initStoreBanners{

    if (self = [super initPOSTWithRequestUrl:KStoreBannersURL]) {
        [self.paramsDic setValue:@"index" forKey:@"index"];

    }
    return self;
}


/**
 获取分类信息
 */
-(instancetype)initStoreClasses{
    if (self = [super initGETWithRequestUrl:KStoreClassesURL]) {
        
        [self.paramsDic setValue:@"1" forKey:@"dept"];
        [self.paramsDic setValue:@"Cosmetology" forKey:@"typeKey"];
        
    }
    return self;
    
}

/**
 商品详情
 
 @param key id
 */
-(instancetype)initStoreItemDetailWithKey:(NSString *)key{
    
    if (self = [super initGETWithRequestUrl:KStoreItemDetailURL]) {
        
        [self.paramsDic setValue:key forKey:@"key"];
        
    }
    return self;
}

/**
 商品内容详情
 
 @param key 商品详情
 
 */
-(instancetype)initGetItemexplainWithKey:(NSString *)key{
    
    if (self = [super initGETWithRequestUrl:KGetItemexplainURL]) {
        
        [self.paramsDic setValue:key forKey:@"key"];
        
    }
    return self;
    
    
}
#pragma mark ---购物车
/**
 购物车列表
 
 @param page 当前页
 */
-(instancetype)initShopCarListWithPage:(NSInteger)page type:(NSString *)type{
    if (self = [super initGETWithRequestUrl:KStoreShopCarListURL]) {
        [self.paramsDic setValue:@(page).stringValue forKey:@"page"];
        [self.paramsDic setValue:type forKey:@"type"];

    }
    return self;
    
}

/**
 添加购物车
 
 @param qty 数量
 @param saleEntityId 商品id
 @param skuId skuId
 */
-(instancetype)initAddShopCarWithQty:(NSString *)qty saleEntityId:(NSString *)saleEntityId skuId:(NSString *)skuId{
    
    if (self = [super initPOSTWithRequestUrl:KStoreAddShopCarURL]) {
        
        [self.paramsDic setValue:qty forKey:@"qty"];
        [self.paramsDic setValue:saleEntityId forKey:@"saleEntityId"];
        [self.paramsDic setValue:skuId forKey:@"skuId"];
        
    }
    return self;
}

/**
 修改购物车数量
 
 @param qty 数量
 @param key  id
 */
-(instancetype)initChangeShopCarCountWithQty:(NSString *)qty key:(NSString *)key{
    if (self = [super initPOSTWithRequestUrl:KStoreChangeShopCarCountURL]) {
        
        [self.paramsDic setValue:qty forKey:@"qty"];
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
    
}

/**
 删除购物车
 
 @param ids 购物车ids
 */
-(instancetype)initDeleteShopCarCountWithIds:(NSString *)ids{
    
    if (self = [super initGETWithRequestUrl:KStoreDeleteShopCarCountURL]) {
        [self.paramsDic setValue:ids forKey:@"ids"];
    }
    return self;
}

#pragma mark ---订单

/**
 提交订单
 
 @param addrId 收货地址
 @param carItemIds 购物车id
 @param id sku
 @param leaveWord 留言
 @param qty 数量
 @param soEntityJsons 参数
 @param groupId 团购id
 @param type 类型 1=预订商城，2=所乐多，3=乐多兑换
 
 */
-(instancetype)initStoreSureOrderWithAddrId:(NSString *)addrId carItemIds:(NSString *)carItemIds id:(NSString *)id leaveWord:(NSString *)leaveWord qty:(NSString *)qty soEntityJsons:(NSString *)soEntityJsons groupId:(NSString *)groupId type:(NSString *)type{
    
    if (self = [super initPOSTWithRequestUrl:KStoreSureOrderURL]) {
        [self.paramsDic setValue:addrId forKey:@"addrId"];
        [self.paramsDic setValue:carItemIds forKey:@"carItemIds"];
        [self.paramsDic setValue:id forKey:@"id"];
        [self.paramsDic setValue:leaveWord forKey:@"leaveWord"];
        [self.paramsDic setValue:qty forKey:@"qty"];
        [self.paramsDic setValue:soEntityJsons forKey:@"soEntityJsons"];
        [self.paramsDic setValue:groupId forKey:@"groupId"];
        [self.paramsDic setValue:type forKey:@"type"];
    }
    return self;
    
}

/**
 立即购买
 
  qrty 数量
  skuId id
 @param skuDataJson 组合数据

 */
-(instancetype)initStoreBuyNowWithSkuDataJson:(NSString *)skuDataJson {
    if (self = [super initPOSTWithRequestUrl:KStoreBuyNowURL]) {
        
        [self.paramsDic setValue:skuDataJson forKey:@"skuDataJson"];
        

    }
    return self;
    
}

/**
 立即团购
 
 qrty 数量
 skuId id
 @param skuDataJson 组合数据 [{"qrty":2,"skuId":"100000971000009"}]
 
 @param groupId 团购id
 */
-(instancetype)initStoreGroupBuyNowWithSkuDataJson:(NSString *)skuDataJson groupId:(NSString *)groupId{
    if (self = [super initPOSTWithRequestUrl:KStoreGroupBuyNowURL]) {
        
        [self.paramsDic setValue:skuDataJson forKey:@"skuDataJson"];
        [self.paramsDic setValue:groupId forKey:@"groupId"];

        
    }
    return self;
    
    
}

#pragma mark ----地址

/**
 新增收货地址
 
 @param arId 区id
 @param arName 区名
 @param ciId 市id
 @param ciName 市名
 @param detail 详情
 @param isDefault 是否为默认 N=不是，Y=是
 @param name 收件人
 @param phone 联系电话
 @param prId 省id
 @param prName 省名
 */

-(instancetype)initStoreAddAddressWithArId:(NSString *)arId arName:(NSString *)arName ciId:(NSString *)ciId ciName:(NSString *)ciName detail:(NSString *)detail isDefault:(NSString *)isDefault name:(NSString *)name phone:(NSString *)phone prId:(NSString *)prId prName:(NSString *)prName{
    
    if (self = [super initPOSTWithRequestUrl:KStoreAddressAddURL]) {
        [self.paramsDic setValue:arId forKey:@"arId"];
        [self.paramsDic setValue:arName forKey:@"arName"];
        [self.paramsDic setValue:ciId forKey:@"ciId"];
        [self.paramsDic setValue:ciName forKey:@"ciName"];
        [self.paramsDic setValue:detail forKey:@"detail"];
        [self.paramsDic setValue:isDefault forKey:@"isDefault"];
        [self.paramsDic setValue:name forKey:@"name"];
        [self.paramsDic setValue:phone forKey:@"phone"];
        [self.paramsDic setValue:prId forKey:@"prId"];
        [self.paramsDic setValue:prName forKey:@"prName"];
    }
    return self;
}

/**
 修改收货地址
 
 @param arId 区id
 @param arName 区名
 @param ciId 市id
 @param ciName 市名
 @param detail 详情
 @param isDefault 是否为默认 N=不是，Y=是
 @param name 收件人
 @param phone 联系电话
 @param prId 省id
 @param prName 省名
 */

-(instancetype)initStoreChangeAddressWithArId:(NSString *)arId arName:(NSString *)arName ciId:(NSString *)ciId ciName:(NSString *)ciName detail:(NSString *)detail isDefault:(NSString *)isDefault name:(NSString *)name phone:(NSString *)phone prId:(NSString *)prId prName:(NSString *)prName id:(NSString *)id{
    
    if (self = [super initPOSTWithRequestUrl:KStoreAddressChangeURL]) {
        [self.paramsDic setValue:arId forKey:@"arId"];
        [self.paramsDic setValue:arName forKey:@"arName"];
        [self.paramsDic setValue:ciId forKey:@"ciId"];
        [self.paramsDic setValue:ciName forKey:@"ciName"];
        [self.paramsDic setValue:detail forKey:@"detail"];
        [self.paramsDic setValue:isDefault forKey:@"isDefault"];
        [self.paramsDic setValue:name forKey:@"name"];
        [self.paramsDic setValue:phone forKey:@"phone"];
        [self.paramsDic setValue:prId forKey:@"prId"];
        [self.paramsDic setValue:prName forKey:@"prName"];
        [self.paramsDic setValue:id  forKey:@"id"];
    }
    return self;
}

/**
 删除收货地址
 
 @param key id
 */
-(instancetype)initStoreDeleteAddressWithKey:(NSString *)key{
    
    if (self = [super initGETWithRequestUrl:KStoreAddressDeleteURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
}

/**
 收货地址列表
 
 */
-(instancetype)initGetStoreAddressList{
    if (self = [super initGETWithRequestUrl:KStoreAddressListURL]) {
        
    }
    return self;
}

/**
 设置为默认地址
 
 @param key id
 */
-(instancetype)initStoreSetDefaultAddressWithKey:(NSString *)key{
    
    if (self = [super initGETWithRequestUrl:KStoreSetDefaultAddressURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
}

/**
 收藏列表
 
 @param page 分页
 
 */
-(instancetype)initStoreCollectionListWithPage:(NSInteger )page{
    if (self = [super initGETWithRequestUrl:KStoreCollectionListURL]) {
        [self.paramsDic setValue:@(page).stringValue forKey:@"page"];
    }
    return self;
    
}

/**
 添加收藏
 
 @param saleEntityId     商品id
 */
-(instancetype)initStoreAddCollectionWithSaleEntityId:(NSString *)saleEntityId{
    
    if (self = [super initPOSTWithRequestUrl:KStoreAddCollectionURL]) {
        [self.paramsDic setValue:saleEntityId forKey:@"saleEntityId"];
    }
    return self;
    
}

/**
 订单列表
 
 @param page     当前页
 @param soStatus 状态 all=全部，awaiting_pay=等待支付；cancelled=取消； awaiting_ship=已支付，等待发货；shipped=已发货；completed=待评价
 */
-(instancetype)initStoreOrderListWithPage:(NSInteger )page soStatus:(NSString *)soStatus{
    
    if (self = [super initGETWithRequestUrl:KStoreOrderListURL]) {
                [self.paramsDic setValue:@(page).stringValue forKey:@"page"];
        [self.paramsDic setValue:soStatus forKey:@"soStatus"];
    }
    return self;
    
}


/**
 订单详情
 
 @param key 订单id
 */
-(instancetype)initStoreOrderDetailWithKey:(NSString * )key{
    
    if (self = [super initGETWithRequestUrl:KStoreOrderDetailURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
}
/**
 取消订单
 
 @param key 订单id
 
 */
-(instancetype)initStoreCancelOrderWithKey:(NSString * )key{
    
    if (self = [super initPOSTWithRequestUrl:KStoreCancelOrderURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
}

/**
 确认收货
 
 @param key 订单id
 */
-(instancetype)initStoreConfirmReceiptWithKey:(NSString * )key{
    if (self = [super initGETWithRequestUrl:KStoreConfirmReceiptURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
    }
    return self;
    
}

/**
 评论列表
 
 @param pageNo 当前页
 @param reviewType 类型
 @param saleEntityId 商品id
 */
-(instancetype)initProductEvaluateListWithPageNo:(NSInteger)pageNo reviewType:(NSString * )reviewType saleEntityId:(NSString * )saleEntityId{
    if (self = [super initGETWithRequestUrl:KProductEvaluateListURL]) {
        [self.paramsDic setValue:@(pageNo).stringValue forKey:@"pageNo"];
        [self.paramsDic setValue:reviewType forKey:@"reviewType"];
        [self.paramsDic setValue:saleEntityId forKey:@"saleEntityId"];
    }
    return self;
    
    
}

/**
 订单评论
 
 @param content 内容
 @param imgUrl 图片
 @param score 心数
 @param soId 订单明细id
 @param type 类型  good_review=好评；middle_review=中评；mistake_review=差评。
 */
-(instancetype)initUploadProductEvaluateWithContent:(NSString *)content imgUrl:(NSString * )imgUrl score:(NSString * )score soId:(NSString * )soId type:(NSString * )type{
    
    if (self = [super initPOSTWithRequestUrl:KUploadProductEvaluateURL]) {
        [self.paramsDic setValue:content forKey:@"content"];
        [self.paramsDic setValue:imgUrl forKey:@"imgUrl"];
        [self.paramsDic setValue:score forKey:@"score"];
        [self.paramsDic setValue:soId forKey:@"soId"];
        [self.paramsDic setValue:type forKey:@"type"];

    }
    return self;
}

/**
 发起退换货服务
 
 @param bizType 业务类型 return=退货；exchange=换货
 @param imageurls 图片
 @param reasonName 原因
 @param skuCount 数量
 @param soItemId 订单id
 */
-(instancetype)initStoreLaunchReturnWithBizType:(NSString * )bizType imageurls:(NSString * )imageurls reasonName:(NSString * )reasonName skuCount:(NSString * )skuCount soItemId:(NSString * )soItemId{
    
    if (self = [super initPOSTWithRequestUrl:KStoreLaunchReturnURL]) {
        [self.paramsDic setValue:bizType forKey:@"bizType"];
        [self.paramsDic setValue:imageurls forKey:@"imageurls"];
        [self.paramsDic setValue:reasonName forKey:@"reasonName"];
        [self.paramsDic setValue:skuCount forKey:@"skuCount"];
        [self.paramsDic setValue:soItemId forKey:@"soItemId"];
        
    }
    return self;
}

/**
 获取退货原因列表
 */
-(instancetype)initGetReturnReason{
    
    if (self = [super initGETWithRequestUrl:KGetReturnReasonURL]) {
        [self.paramsDic setValue:@"1" forKey:@"dept"];
        [self.paramsDic setValue:@"afterService" forKey:@"typeKey"];
        
    }
    return self;
    
}

/**
 获取退换货列表
 
 @param page 分页
 
 */
-(instancetype)initGetAfterSaleListWithPage:(NSInteger)page{
    
    
    if (self = [super initGETWithRequestUrl:KGetAfterSaleListURL]) {
        [self.paramsDic setValue:@(page).stringValue forKey:@"page"];
        
    }
    return self;
    
}

/**
 退货详情
 
 @param key 退货id
 */
-(instancetype)initAfterSaleDetailWithKey:(NSString *)key{
    
    if (self = [super initGETWithRequestUrl:KAfterSaleDetailURL]) {
        [self.paramsDic setValue:key forKey:@"key"];
        
    }
    return self;
}
/**
 用户退货资料
 
 @param addr 详情地址
 @param exShipName 发货快递公司
 @param exTrackingNo 发货单号
 @param key 退货id
 @param mobile 收货手机号
 @param person 收货人
 */
-(instancetype)initAfterSaleAddressAndsendWithAddr:(NSString *)addr exShipName:(NSString *)exShipName exTrackingNo:(NSString *)exTrackingNo key:(NSString *)key  mobile:(NSString *)mobile  person:(NSString *)person{
    
    if (self = [super initPOSTWithRequestUrl:KAfterSaleAddressAndsendURL]) {
        [self.paramsDic setValue:addr forKey:@"addr"];
        [self.paramsDic setValue:exShipName forKey:@"exShipName"];
        [self.paramsDic setValue:exTrackingNo forKey:@"exTrackingNo"];
        [self.paramsDic setValue:key forKey:@"key"];
        [self.paramsDic setValue:mobile forKey:@"mobile"];
        [self.paramsDic setValue:person forKey:@"person"];
    }
    return self;
}


/**
 获取物流详情
 
 @param soEntityId 订单id
 */
-(instancetype)initLogisticsDetailWithSoEntityId:(NSString *)soEntityId{
    
    if (self = [super initGETWithRequestUrl:KLogisticsDetailURL]) {
        [self.paramsDic setValue:soEntityId forKey:@"soEntityId"];
        
    }
    return self;
    
}
@end
